#include "basic_typedef.h"
#include <iostream>
#include <string>
#include <list>
#include <CGAL/intersections.h>
#include <boost/timer.hpp>

using namespace std;

typedef Polygon::Vertex_const_iterator Vit;
typedef Polygon::Edge_const_iterator Edge_it;

class TrianglesCreator
{
public:
	static vector<Polygon> get_covered_triangles(const Polygon& polygon, const Point& guard);

private:
	static vector<Segment> get_edges(const Polygon& polygon);
	static PointsVector get_intersections_with_edges(const Ray& ray, const vector<Segment>& edges, const Point& vertex);
	static bool intersect_segment_and_ray(const Segment& seg, const Ray& ray, Point& intersection_point);
	static bool guard_sees_vertex(const Polygon& polygon, const PointsVector& intersections, const Point& guard, const Point& vertex);
	static Segment get_triangle_edge(const Point& guard, const Segment& curr_edge, const Segment& next_edge, const PointsVector& intersections, bool first_edge);
	static bool intersection_closer_to_guard(const Point& guard, const Point& vertex, const Point& intersection_point);
	static Point get_closest_intersection(const Point& guard, const PointsVector& intersections);
	static Segment get_next_edge(const Polygon& polygon, const Edge_it& eit);
	static void get_arrangement_of_triangle(vector<Polygon>& arr, const Point& point1, const Point& point2, const Point& point3);
};